package o;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.ResolveInfo;
import android.os.UserManager;
import android.text.TextUtils;
import com.huawei.android.app.ActivityManagerEx;
import com.huawei.android.content.pm.PackageManagerEx;
import com.huawei.android.content.pm.UserInfoEx;
import com.huawei.android.internal.util.ScreenshotHelperEx;
import com.huawei.android.os.UserManagerEx;
import com.huawei.gamebox.plugin.gameservice.bean.GameInfo;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

public class big {
    static List<String> ˏ(GameInfo gameInfo) {
        List<String> ॱ = bib.ॱ(gameInfo);
        Collection ˎ = bii.ˎ(gameInfo);
        if (!CollectCheck.isEmpty(ॱ)) {
            ॱ.retainAll(ˎ);
        }
        return ॱ;
    }

    public static List<String> ˎ() {
        fae ˏ = fam.ॱ().ˏ();
        if (ˏ != null) {
            return ˏ(ˏ.getGameInfo());
        }
        Logger.e("GameModeChecker", "buoyBridge == null");
        return null;
    }

    public static boolean ˋ(GameInfo gameInfo) {
        if (gameInfo == null) {
            Logger.e("GameModeChecker", "isGameModeSupported return false because the param[gameInfo] is null");
            return false;
        } else if (CollectCheck.isEmpty(ˏ(gameInfo)) || !bii.ˎ(gameInfo.getPackageName())) {
            return false;
        } else {
            return true;
        }
    }

    public static boolean ˏ(boolean z) {
        List ˎ;
        if (z) {
            if (Logger.ˎ()) {
                Logger.ˏ("GameModeChecker", "is offline mode");
            }
            fae ˏ = fam.ॱ().ˏ();
            if (ˏ == null) {
                Logger.e("GameModeChecker", "buoyBridge == null");
                return false;
            }
            ˎ = bii.ˎ(ˏ.getGameInfo());
        } else {
            ˎ = ˎ();
        }
        if (CollectCheck.isEmpty(ˎ)) {
            return false;
        }
        boolean z2 = ˎ.contains("game_power_save_mode") || ˎ.contains("game_dnd_mode") || ˎ.contains("game_deep_nodisturb_mode") || ˎ.contains("game_key_control_mode") || ˎ.contains("keep_luminance");
        return z2;
    }

    public static boolean ॱ(GameInfo gameInfo) {
        if (gameInfo == null) {
            Logger.e("GameModeChecker", "isGameModeSupported return false because the param[gameInfo] is null");
            return false;
        } else if (CollectCheck.isEmpty(bii.ˎ(gameInfo)) || !bii.ˎ(gameInfo.getPackageName())) {
            return false;
        } else {
            return true;
        }
    }

    static boolean ॱ() {
        if (bka.ॱ("ro.config.hw_front_fp_navi", false) || bka.ˏ("ro.config.gameassist.anti-touch", 0) == 1) {
            return true;
        }
        return false;
    }

    static boolean ˋ() {
        boolean z = true;
        if (!ʻ()) {
            return false;
        }
        if (bka.ˏ("ro.config.gameassist_soundtovibrate", 0) != 1) {
            z = false;
        }
        return z;
    }

    public static boolean ˎ(GameInfo gameInfo) {
        if (gameInfo == null || TextUtils.isEmpty(gameInfo.getPackageName())) {
            Logger.e("GameModeChecker", "gameinfo is null or gameinfo.packageName is null");
            return false;
        } else if (!ˋ()) {
            return false;
        } else {
            List asList = Arrays.asList(ContentManager.getInstant().getContext().getResources().getStringArray(beo$c.ˏ));
            if (gameInfo.getPackageName().contains("com.netease.hyxd.") || (!CollectCheck.isEmpty(asList) && asList.contains(gameInfo.getPackageName()))) {
                return true;
            }
            return false;
        }
    }

    public static boolean ˊ() {
        boolean z = true;
        if (!ʻ()) {
            return false;
        }
        if (bka.ˏ("ro.config.gameassist.nodisturb", 0) != 1) {
            z = false;
        }
        return z;
    }

    public static boolean ˏ() {
        return bka.ॱ("ro.config.hw_freeform_enable", false);
    }

    static boolean ʼ() {
        try {
            ScreenshotHelperEx screenshotHelperEx = new ScreenshotHelperEx(fis.ˎ());
            return true;
        } catch (Throwable th) {
            Logger.e("GameModeChecker", "ScreenshotHelperEx init throw throwable");
            return false;
        }
    }

    static boolean ॱॱ() {
        if (ʻ() && bka.ॱ("ro.config.hw_triple_finger", false) && bka.ॱ("ro.config.disable_triple", false)) {
            return true;
        }
        return false;
    }

    public static boolean ˎ(String str) {
        return !TextUtils.isEmpty(str) && cep.ˋ(fis.ˎ(), str);
    }

    public static boolean ʻ() {
        return azc.ˎ().ॱ() < 17 || ˎ("com.huawei.gameassistant");
    }

    public static boolean ʽ() {
        return ˎ("com.huawei.screenrecorder");
    }

    public static boolean ˊ(String str) {
        return ˏ(str, true) != null;
    }

    public static bhp ˏ(String str, boolean z) {
        try {
            int currentUser = ActivityManagerEx.getCurrentUser();
            Context ˎ = fis.ˎ();
            for (UserInfoEx userInfoEx : UserManagerEx.getProfiles((UserManager) ˎ.getSystemService("user"), currentUser)) {
                if ((z && userInfoEx.isClonedProfile()) || (!z && !userInfoEx.isClonedProfile())) {
                    return ˎ(str, ˎ, userInfoEx);
                }
            }
        } catch (Throwable th) {
            Logger.ˋ("GameModeChecker", "getStartAppInfo error", th);
        }
        return null;
    }

    private static bhp ˎ(String str, Context context, UserInfoEx userInfoEx) {
        Intent intent = new Intent("android.intent.action.MAIN");
        intent.addCategory("android.intent.category.LAUNCHER");
        intent.setPackage(str);
        List queryIntentActivitiesAsUser = PackageManagerEx.queryIntentActivitiesAsUser(context.getPackageManager(), intent, 0, userInfoEx.getUserInfoId());
        if (CollectCheck.isEmpty(queryIntentActivitiesAsUser)) {
            return null;
        }
        ActivityInfo activityInfo = ((ResolveInfo) queryIntentActivitiesAsUser.get(0)).activityInfo;
        intent.setComponent(new ComponentName(activityInfo.packageName, activityInfo.name));
        return new bhp((ResolveInfo) queryIntentActivitiesAsUser.get(0), intent, userInfoEx);
    }

    public static boolean ˏ(String str) {
        try {
            int currentUser = ActivityManagerEx.getCurrentUser();
            Boolean bool = (Boolean) Class.forName("com.huawei.android.content.pm.PackageManagerEx").getMethod("shouldSkipTriggerFreeform", new Class[]{String.class, Integer.TYPE}).invoke(null, new Object[]{str, Integer.valueOf(currentUser)});
            Logger.ˎ("GameModeChecker", "shouldSkipFreeForm " + str + ":" + bool);
            return bool.booleanValue();
        } catch (Throwable th) {
            Logger.e("GameModeChecker", "shouldSkipFreeForm exception");
            return false;
        }
    }
}
